Sorting Folder Project Module Level while excel export

With reference to the previous thread on Levels [https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014466595&ps=25], I had minimal changes on the shared script as below. 

Current Export

The levels are printed along with the Project / Folder / Module correctly like the attached "Current Export.jpg"

 

Expected Export :

Is there a way I can have all the Level segregated inlineD with the Parent so that they have the DOORS like structure , as in the attached "Expected Export.jpg"

 

int lev = 1
Project p = current Project
Item it
Stream outfile = write "H:\\AllWithLevels.csv"
        
        outfile << "Level," 
        outfile << "Folders," "\n"
void processItem(Item i)
{
                
        outfile << "\"" lev "\"," 
                outfile << "\"" name i "\"," "\n"
        
        if (type i == "Project" || type i == "Folder")
        {
                lev++
                Item j
                for j in folder fullName i do
                {
                        if (type j == "Project") continue
                        processItem j
                }
                lev--
        }
}
processItem item fullName p
close outfile
infoBox  "Export Completed"

 


HKrishnan - Thu Nov 10 03:52:42 EST 2016

Re: Sorting Folder Project Module Level while excel export
Mathias Mamsch - Thu Nov 10 04:04:18 EST 2016

you need to export as many commas (empty fields) as the level is before the name, to create that kind of indentation. Regards, Mathias

Re: Sorting Folder Project Module Level while excel export
HKrishnan - Thu Nov 10 05:21:30 EST 2016

Mathias Mamsch - Thu Nov 10 04:04:18 EST 2016

you need to export as many commas (empty fields) as the level is before the name, to create that kind of indentation. Regards, Mathias

Thanks Mathias Mamsch Tried that .. No luck.. Hence had to post n here. 

 

Wen I give the commas all of em are aligned in the same column. It would be great if you share some sample or help in my above snippet. 

 

Thanks

HK

Re: Sorting Folder Project Module Level while excel export
Mathias Mamsch - Thu Nov 10 06:39:12 EST 2016

HKrishnan - Thu Nov 10 05:21:30 EST 2016

Thanks Mathias Mamsch Tried that .. No luck.. Hence had to post n here. 

 

Wen I give the commas all of em are aligned in the same column. It would be great if you share some sample or help in my above snippet. 

 

Thanks

HK

Maybe you should post the version of the script with the commas, since the above script definitely does not export multiple commas.

For a level three item, you need to export:

3,,,My Name

Your script only exports: 

3,My Name

Regards, Mathias

Re: Sorting Folder Project Module Level while excel export
DOORSHAM - Thu Nov 10 08:56:46 EST 2016

Mathias Mamsch - Thu Nov 10 06:39:12 EST 2016

Maybe you should post the version of the script with the commas, since the above script definitely does not export multiple commas.

For a level three item, you need to export:

3,,,My Name

Your script only exports: 

3,My Name

Regards, Mathias

The following will be closer to what users wants:

 

//Simulate_DOORS_Structure.dxl
/*Generates CSV file that can be read by excel*/
int lev = 1
Project p = current Project
Item it
Buffer b = create
Stream outfile = write "H:\\AllWithLevels.csv"
  
b= "Level,Folders\n"
void processItem(Item i)
{  if( lev ==  1)  b+= lev",\"" name i "\"\n"
   if( lev ==  2)  b+= lev",,\"" name i "\"\n"
   if( lev ==  3)  b+= lev",,,\"" name i "\"\n"
   if( lev ==  4)  b+= lev",,,,\"" name i "\"\n"
   if( lev ==  5)  b+= lev",,,,,\"" name i "\"\n"
   if( lev ==  6)  b+= lev",,,,,,\"" name i "\"\n"
   if( lev ==  7)  b+= lev",,,,,,,\"" name i "\"\n"
   if( lev ==  8)  b+= lev",,,,,,,,\"" name i "\"\n"
   if( lev ==  9)  b+= lev",,,,,,,,,\"" name i "\"\n"
   if( lev ==  10)  b+= lev",,,,,,,,,\"" name i "\"\n"
   if( lev ==  11)  b+= lev",,,,,,,,,,\"" name i "\"\n"
   if( lev ==  12)  b+= lev",,,,,,,,,,,\"" name i "\"\n"
   if (type i == "Project" || type i == "Folder")
   {  lev++
      Item j
      for j in folder fullName i do
      {  if (type j == "Project") continue
         processItem j
      }
      lev--
   }
}
processItem item fullName p
print b ""
outfile << b""
delete b
close outfile
infoBox  "Export Completed"